package com.gxan.service.impl;

import com.gxan.dao.TrainingDao;
import com.gxan.dao.impl.TrainingDaoImpl;
import com.gxan.pojo.Training;
import com.gxan.service.TrainingService;
import org.apache.commons.beanutils.BeanUtils;

import java.lang.reflect.InvocationTargetException;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

//培训管理service
public class TrainingServiceImpl implements TrainingService {
    private TrainingDao trainingDao = new TrainingDaoImpl();
    //查询所有培训计划
    @Override
    public List<Training> findTrainingAll(Integer page,Integer limit) throws SQLException {
        Integer offset = (page-1)*limit;
        Integer rows = limit;
        return trainingDao.finTrainingAll(offset,rows);
    }
    //新增培训计划
    @Override
    public int addTraining(Training training) throws SQLException {
        return trainingDao.addTraining(training);
    }
    //查询总条数
    @Override
    public Integer countTraining() throws SQLException {
        return trainingDao.countTraining();
    }
    //修改培训计划
    @Override
    public int updateTraining(Training training) throws SQLException {
        return trainingDao.updateTraining(training);
    }
    //根据id删除培训计划
    @Override
    public int deleteTrainingById(Integer training_id) throws SQLException {
        return trainingDao.deleteTrainingById(training_id);
    }
    //按条件搜索
    @Override
    public List<Training> searchTrainings(Integer page, Integer limit, String training_name, String audit_status, String start_time, String end_time) throws SQLException {
        Integer offset = (page - 1) * limit;
        Integer rows = limit;
        return trainingDao.searchTraining(offset,rows,training_name,audit_status,start_time,end_time);
    }
    //查询搜索的总条数
    @Override
    public int countTrainingByParams(String training_name, String audit_status, String start_time, String end_time) throws SQLException {
        return trainingDao.countTrainingByParams(training_name,audit_status,start_time,end_time);
    }
    //修改审核状态====通过审核
    @Override
    public int checkTraining(Training training) throws SQLException {
        return trainingDao.checkTraining(training);
    }
    //修改审核状态====驳回
    @Override
    public int rejectTraining(Training training) throws SQLException {
        return trainingDao.rejectTraining(training);
    }
    //添加培训计划与反馈
    @Override
    public int feedbackAddTraining(Training training) throws SQLException {
        return trainingDao.feedbackAddTraining(training);
    }
}
